<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
      <title>資料映射 | HiAPI-C# 2025 </title>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta name="title" content="資料映射 | HiAPI-C# 2025 ">
      
      
      <link rel="icon" href="../../../../../img/HiAPI.favicon.ico">
      <link rel="stylesheet" href="../../../../../public/docfx.min.css">
      <link rel="stylesheet" href="../../../../../public/main.css">
      <meta name="docfx:navrel" content="../../../../../toc.html">
      <meta name="docfx:tocrel" content="../../toc.html">
      
      <meta name="docfx:rel" content="../../../../../">
      
      
      
      <meta name="loc:inThisArticle" content="In this article">
      <meta name="loc:searchResultsCount" content="{count} results for &quot;{query}&quot;">
      <meta name="loc:searchNoResults" content="No results for &quot;{query}&quot;">
      <meta name="loc:tocFilter" content="Filter by title">
      <meta name="loc:nextArticle" content="Next">
      <meta name="loc:prevArticle" content="Previous">
      <meta name="loc:themeLight" content="Light">
      <meta name="loc:themeDark" content="Dark">
      <meta name="loc:themeAuto" content="Auto">
      <meta name="loc:changeTheme" content="Change theme">
      <meta name="loc:copy" content="Copy">
      <meta name="loc:downloadPdf" content="Download PDF">

      <script type="module" src="./../../../../../public/docfx.min.js"></script>

      <script>
        const theme = localStorage.getItem('theme') || 'auto'
        document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
      </script>

  </head>

  <body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
    <header class="bg-body border-bottom">
      <nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
        <div class="container-xxl flex-nowrap">
          <a class="navbar-brand" href="../../../../../index.html">
            <img id="logo" class="svg" src="../../../../../img/HiAPI.logo.png" alt="">
            
          </a>
          <button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
            <i class="bi bi-three-dots"></i>
          </button>
          <div class="collapse navbar-collapse" id="navpanel">
            <div id="navbar">
              <form class="search" role="search" id="search">
                <i class="bi bi-search"></i>
                <input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
              </form>
            </div>
          </div>
        </div>
      </nav>
    </header>

    <main class="container-xxl">
      <div class="toc-offcanvas">
        <div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
          <div class="offcanvas-header">
            <h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
            <button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
          </div>
          <div class="offcanvas-body">
            <nav class="toc" id="toc"></nav>
          </div>
        </div>
      </div>

      <div class="content">
        <div class="actionbar">
          <button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
            <i class="bi bi-list"></i>
          </button>

          <nav id="breadcrumb"></nav>
        </div>

        <article data-uid="">
          <h1 id="資料映射">資料映射</h1>

<p>外部資料包含智慧刀把、動力計，可依時間線性映射至指定刀具路徑及加工區域。</p>
<p>映射資料可用於檢視加工狀態、訓練銑削係數、校正銑削係數。</p>
<p>所以資料映射需指定映射之兩部：指定輸入資料、指定NC路徑。</p>
<figure class="alert text-bg-light">
  <img src="Mapping%20Overview%20Example.png" alt="Mapping Overview Example">
  <figcaption>資料映射圖例</figcaption>
</figure>
<h2 id="指定輸入資料">指定輸入資料</h2>
<div class="NOTE">
<h5>Note</h5>
<p><strong>指令格式</strong></p>
<pre><code>AddTimeDataByFile(&lt;映射名&gt;, &lt;輸入檔案路徑&gt;, &lt;映射起點時間&gt;, &lt;映射終點時間&gt;);
</code></pre>
</div>
<p>&lt;映射名&gt;為自訂之標記名稱，對應於指定<strong>NC路徑</strong>中的映射名。</p>
<p>時間資料格式為<code>&lt;時&gt;:&lt;分&gt;:&lt;秒&gt;.&lt;小數點後秒&gt;</code>；其餘資料格式為實數。</p>
<p>注意映射資料不會因撥放器重置而被清空。可以使用<code>ClearTimeMappingData</code>指令清空。</p>
<div class="NOTE">
<h5>Note</h5>
<p><strong>指令格式</strong></p>
<pre><code>ClearTimeMappingData();
</code></pre>
</div>
<div class="TIP">
<h5>Tip</h5>
<p><strong>指令範例</strong></p>
<pre><code>ClearTimeMappingData();
AddTimeDataByFile( &quot;lineA&quot;, &quot;Mapping/sensor1.csv&quot;, &quot;18:25:51.7100&quot;, &quot;18:26:12.9910&quot;);
AddTimeDataByFile( &quot;lineB&quot;, &quot;Mapping/sensor1.csv&quot;, &quot;18:26:30.5750&quot;, &quot;18:27:12.2880&quot;);
PlayNcFile(&quot;NC/file1.nc&quot;)
</code></pre>
</div>
<p>輸入檔案格式為csv，須包含時間資訊，其餘資訊可選擇包含或不包含。</p>
<p>csv檔案需有標題列，欄位標題需用特定指示詞標示。
部分欄位指示詞為方便性是多擇一。</p>
<ul>
<li>時間：
<ul>
<li><code>TimeTag</code></li>
<li><code>Timetag</code></li>
<li><code>Time</code></li>
<li><code>t</code></li>
</ul>
</li>
<li>動力計：
<ul>
<li>X方向力：
<ul>
<li><code>Fx</code></li>
<li><code>Workpiece.Fx</code></li>
</ul>
</li>
<li>Y方向力：
<ul>
<li><code>Fy</code></li>
<li><code>Workpiece.Fy</code></li>
</ul>
</li>
<li>Z方向力：
<ul>
<li><code>Fz</code></li>
<li><code>Workpiece.Fz</code></li>
</ul>
</li>
</ul>
</li>
<li>智慧刀把：
<ul>
<li>X方向力矩：
<ul>
<li><code>Mx</code></li>
<li><code>Spindle.Mx</code></li>
</ul>
</li>
<li>Y方向力矩：
<ul>
<li><code>My</code></li>
<li><code>Spindle.My</code></li>
</ul>
</li>
<li>Z方向力矩：
<ul>
<li><code>Mz</code></li>
<li><code>Spindle.Mz</code></li>
</ul>
</li>
</ul>
</li>
<li>加速規(可選)：
<ul>
<li><code>Ax</code></li>
<li><code>Ay</code></li>
<li><code>Az</code></li>
</ul>
</li>
</ul>
<p>欄位可以包含其他外部資訊，如下例之<code>CH1</code>、<code>CH2</code>。</p>
<div class="TIP">
<h5>Tip</h5>
<p><strong>檔案範例</strong></p>
<pre><code>TimeTag,CH1,CH2,Mx,My,Mz
18:23:54.703,-0.00398,-0.00034,-0.02923,0.10733,0.00409
18:23:54.704,-0.00194,0.00285,0.04155,-0.04457,0.00448
...
</code></pre>
</div>
<h2 id="指定nc路徑">指定NC路徑</h2>
<div class="NOTE">
<h5>Note</h5>
<p><strong>指令格式</strong></p>
<pre><code>//範圍(多行)資料映射
BeginSelection(&lt;映射名&gt;, &lt;起點映射錨點旗標&gt;, &lt;起點偏置物件&gt;);
EndSelection(&lt;映射名&gt;, &lt;終點映射錨點旗標&gt;, &lt;終點偏置物件&gt;);
//單行資料映射
LineSelection(&lt;映射名&gt;, &lt;起點映射錨點旗標&gt;, &lt;起點偏置物件&gt;, &lt;終點映射錨點旗標&gt;, &lt;終點偏置物件&gt;);
</code></pre>
</div>
<p>&lt;映射名&gt;為自訂之標記名稱，對應於指定<strong>輸入資料</strong>中的映射名。</p>
<ul>
<li>可以使用<code>BeginSelection</code>與<code>EndSelection</code>作範圍(多行)資料映射：
<ul>
<li><code>BeginSelection</code>設置映射起點。</li>
<li><code>EndSelection</code>設置映射終點。</li>
</ul>
</li>
<li>或是使用<code>LineSelection</code>作單行資料映射。</li>
</ul>
<p>&lt;映射錨點旗標&gt;可以使用：</p>
<ul>
<li><code>LineBegin</code>
以該行運動起點為映射錨點。</li>
<li><code>LineEnd</code>
以該行運動終點為映射錨點。</li>
<li><code>FirstTouch</code>
以該行第一次接觸工件的位置為映射錨點。</li>
<li><code>LastTouch</code>
以該行最後接觸工件的位置為映射錨點。</li>
</ul>
<blockquote>
<p><img src="markRegionOnTouch.png" alt="markRegionOnTouch.png"></p>
</blockquote>
<p>&lt;偏置物件&gt;是相對於錨點的偏移，可以使用：</p>
<ul>
<li><code>null</code>
無偏移。</li>
<li><code>ShiftTime_s</code>
單位秒。正值為往後時間；負值為往前時間。</li>
<li><code>ShiftDistance_mm</code>
單位mm。正值為往後位移；負值為往前位移。</li>
</ul>
<p>指定NC路徑命令需在NC碼註解中執行，前置<code>;@</code>符號。</p>
<div class="TIP">
<h5>Tip</h5>
<p><strong>NC檔案範例</strong></p>
<pre><code>...
G00 G90 X-6. Y10.  
G17 G01 Z-1. F600.
S50 M03
X13. F20 ;@LineSelection(&quot;lineA&quot;, FirstTouch, ShiftTime_s(2), LineEnd, ShiftDistance_mm(-1));
X25. F10 ;@LineSelection(&quot;lineB&quot;, FirstTouch, null, LastTouch, null);
...
</code></pre>
</div>
<div class="TIP">
<h5>Tip</h5>
<p><strong>NC檔案範例2</strong></p>
<p>如果控制器不支援<code>;</code>符號作為註解，如FANUC控制器，則需將其引入註解範圍內。</p>
<pre><code>...
G00 G90 X-6. Y10.  
G17 G01 Z-1. F600.
S50 M03
X13. F20 (;@LineSelection(&quot;lineA&quot;, FirstTouch, ShiftTime_s(2), LineEnd, ShiftDistance_mm(-1));)
X25. F10 (;@LineSelection(&quot;lineB&quot;, FirstTouch, null, LastTouch, null);)
...
</code></pre>
</div>

</article>

        <div class="contribution d-print-none">
        </div>

        <div class="next-article d-print-none border-top" id="nextArticle"></div>

      </div>

      <div class="affix">
        <nav id="affix"></nav>
      </div>
    </main>

    <div class="container-xxl search-results" id="search-results"></div>

    <footer class="border-top text-secondary">
      <div class="container-xxl">
        <div class="flex-fill">
          <span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
        </div>
      </div>
    </footer>
  </body>
</html>
